$().ready(function(){
	$("#img_show").load(function(){
			var w=$(this).width();
			w=parseInt(w);
			if(w>600){
				$(this).width(600);
			}

		});
	initComment();
})

function initComment(){
	$(".comments_text>textarea").val("").attr("disabled",'');
	$(".submitbtn").click(function(){//提交内容
	if(window.uploading==true){
		alert('正在提交，请等待！');
		return false;
	}
		var content=$(".comments_text>textarea").val();
		if(!content){alert("内容不能为空！");return false;}
		if(content.length<2){alert("内容不能小于两个字!");return false;}
		if(content.length>200){
			if(!confirm('字符超过限制，系统将自动截取200个字，是否继续？')){
				return false;
			}
			content=content.subString(0,200);
		}
		//$(".comments_text>textarea").attr("disabled",'disabled');
		window.uploading=true;
		var type=$(".comments_text>textarea").attr('con_type');
		$.ajax({type:"POST",dataType:"json",data:{"dataFromType":"ajax","act":"add_comment",'type':(type||''),"content":content,"app_id":($("#app_id").val())},url:($("#newsurl").val())+"e/comment/",success:function(r){
			if(r.flag==1){
				$(".comments_text>textarea").val("").attr("disabled",'');
				window.uploading=false;
				loadComment(1);					
				return false;
			}else if(r.msg){alert(r.msg);window.uploading=false;}else{alert("系统错误，请与管理员联系");window.uploading=false;}
				
	}});	
	});
	loadComment(1);
}
function loadComment(p){
	var height=$(".list-c-items").height();
	$(".list-c-items").html('加载中...');
	//$(".list-c-items").css("height",height);
	var type=$(".comments_text>textarea").attr('con_type');
	var url=($("#newsurl").val())+"e/comment/list.php?p="+(p?p:1)+"&app_id="+($("#app_id").val())+"&type="+type+"&tmp="+parseInt(Math.random()*10000);
	$(".list-c-items").load(url,function(){
		//$(".list-c-items").css("height","auto");
		var cmNum=$("#cmmt_t_num").val();
		$(".comment_num").html(cmNum);
	})
}
function initFlashUpload(){
	$('#file_upload').uploadify({
			'uploader'       : ($("#newsurl").val())+'skin/jquery.uploadify-v2.1.4/uploadify.swf',
			'script'         : ($("#newsurl").val())+'e/jat/act_up_pic.php',
			'cancelImg'      : ($("#newsurl").val())+'skin/jquery.uploadify-v2.1.4/cancel.png',
			'folder'         : ($("#newsurl").val())+'skin/upload',
			'multi'          : true,
			'auto'           : false,
			"scriptData"	 : {"id":$("#artcile_id").val(),'sid':($("#session_id").val()||"")},
			'onComplete'  : function(event, ID, fileObj, response, data) {						
				var o=getObject(response)
			if(o){
				if(o.flag==1){
					alert(o.id);
				}else{
					alert(o.msg);
				}
			}else{
				alert('系统错误！');
			}		
		},
		"":function(){
		
		},
		"onAllComplete"	:function(){					
			//$(".list-p").append("<div class='clear'></div>");
			//$(".ok_div").show();
		}
		  });
}